import {Dimensions, Image} from 'react-native';
import React from 'react';
import {PHOTO_URL} from '../utils/api';
export default function PhotoView({route, navigation}) {
  const {stuid} = route.params;
  //alert(stuid);
  const {width, height} = Dimensions.get('window');

  const randomString = () => {
    let len = 6;
    let $chars = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefhijklmnprstuvwxyz0123456789';
    let maxPos = $chars.length;
    let pwd = '';
    for (let i = 0; i < len; i += 1) {
      pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
    }
    return pwd;
  };

  return (
    <Image
      source={{
        uri: `${PHOTO_URL}/${stuid}_img.png?${randomString()}`,
      }}
      style={{width: width, height: height - 20, resizeMode: 'contain'}}
    />
  );
}
